<template>
	<view class="temListSearch conTainer">
		<view class="searchText f16">
			标签
		</view>
		<view>
			<uni-easyinput type="text" :clear="false" v-model="tags" placeholder="请输入描述标签" />
		</view>
		<view class="searchText f16">
			队伍名字
		</view>
		<view>
			<uni-easyinput type="text" :clear="false" v-model="formData.teamName" placeholder="请输入队伍名字" />
		</view>
		<view class="searchText f16">
			队伍类型
		</view>
		<view>
			<uni-data-checkbox v-model="formData.teamType" :localdata="temType" />
		</view>
		<view class="searchText f16">
			组织类型
		</view>
		<view>
			<uni-data-checkbox v-model="formData.type" :localdata="team" />
		</view>
		<view class="searchText f16">
			项目名称
		</view>
		<view>
			<uni-easyinput type="text" :clear="false" v-model="formData.teamProjectName"
				placeholder="请输入想要的比赛/项目/其他名称" />
		</view>
		<view class="button">
			<view type="primary" class="button_item f14 margin-right16" @click="reset">重置</view>
			<view type="primary" class="button_item f14" @click="search">搜索</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tags: '',
				formData: {
					tags: [],
					type: 3,
					teamName: '',
					teamProjectName: '',
					teamType: 6,
				},
				team: [{
					text: '不限',
					value: 3
				}, {
					text: '个人',
					value: 1
				}, {
					text: '组织',
					value: 0
				}],
				temType: [{
					text: '不限',
					value: 6
				}, {
					text: '平台比赛',
					value: 1
				}, {
					text: '平台项目',
					value: 2
				}, {
					text: '自定义比赛',
					value: 3
				}, {
					text: '自定义项目',
					value: 4
				}, {
					text: '其他',
					value: 5
				}],
			}
		},
		methods: {
			reset() {
				this.tags = ''
				this.formData.teamName = ''
				this.formData.tags = []
				this.formData.type = 3
				this.formData.teamProjectName = ''
				this.formData.teamType = 6
			},
			search() {

				let data;
				if (!this.tags) {
					data = {
						...this.formData,
						tags: [],
						type: this.formData.type == 3 ? null : this.formData.type,
						teamType: this.formData.teamType == 6 ? null : this.formData.teamType,
					}
				} else {
					let newTags = [this.tags]
					data = {
						...this.formData,
						tags: newTags,
						type: this.formData.type == 3 ? null : this.formData.type,
						teamType: this.formData.teamType == 6 ? null : this.formData.teamType,
					}
				}
				console.log(data, 76);
				this.$emit('closePopup')
				this.$nextTick(() => {
					this.$emit('searctReload', data)
				})
			},
		},
		created() {

		}
	}
</script>

<style scoped lang="less">
	.temListSearch {
		height: auto;
		background-color: #fff;

		.uni-select__selector {
			z-index: 99;
		}

		.button {
			display: flex;
			margin-top: 15rpx;
			justify-content: center;

			&_item {
				width: auto;
				background-color: #2ebef3;
				color: #fff;
				padding: 15rpx 35rpx;
				border-radius: 15rpx;
			}
		}

		.searchText {

			margin: 15rpx 0;
		}
	}
</style>
